﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Cloud.Model;
using Cloud.BLL;

public partial class Three_Managerment_P0401_Save : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        try
        {
            if (Session["users"] == null)
            {
                Response.Write("<script>alert('登录超时'); window.parent.location.href='/index.html'</script>");
            }
            if (!IsPostBack)
            {
                string sql7 = " insert into Problem values(1,ISNULL((( select CONVERT (bigint, (SELECT top(1) appealid FROM problem WHERE regtime >(select cast(convert(varchar(10),getdate(),120)+' 00:00:00' as datetime) )order by id desc) )+1)),(convert(varchar(10),getdate(),112 )+'00001')),GETDATE(),'1900-01-01 00:00:00','1900-01-01 00:00:00', 0,'','','',0,0,0,0,0,0,0,0,0,0,0 ,'','','','','' ,'','','',0,0,0,0,0 ,0,0)select @@identity as num ";
                String bh = ProblemManager.FindById(Convert.ToInt32(ProblemManager.pcount(sql7))).Appealid;

                biaohao.Value = bh;
                this.drot.DataSource = SourcesManager.FindAll();
                this.drot.DataTextField = "name";
                this.drot.DataValueField = "id";
                this.drot.DataBind();

                this.guishu.DataSource = AscriptionManager.FindAll();
                this.guishu.DataTextField = "name";
                this.guishu.DataValueField = "id";
                this.guishu.DataBind();

                this.feilei.DataSource = Classification_Appeal1Manager.FindAll();
                this.feilei.DataTextField = "name";
                this.feilei.DataValueField = "id";
                this.feilei.DataBind();

                this.xiaolei.DataSource = Classification_Appeal2Manager.FindBySort(Convert.ToInt32(this.feilei.SelectedItem.Value));
                this.xiaolei.DataTextField = "name";
                this.xiaolei.DataValueField = "id";
                this.xiaolei.DataBind();
                if (((USER_INFO)Session["users"]).USER_ID.Equals("u2"))
                {
                    this.num.Value = "0";
                }
                else
                {
                    this.num.Value = ((USER_INFO)Session["users"]).USER_ID;
                }
            }
        }
        catch (Exception ex)
        {

            Response.Write("<script>alert('登陆信息失效,请重新登陆!'); window.parent.location.href='/index.html'</script>");
            return;
        }
    }
    protected void Unnamed_Click(object sender, EventArgs e)
    {

        if (Session["users"] == null)
        {
            Response.Write("<script>alert('登录超时'); window.parent.location.href='/index.html'</script>");
        }
        Problem activity = ProblemManager.findappid(this.biaohao.Value);

        if (rad.Checked)
        {
            activity.Opens = 1;
        }
        else
        {
            activity.Opens = 0;
        }

        if (rad3.Checked)
        {
            activity.Important = 1;
        }
        else
        {
            activity.Important = 0;
        }

        if (rad5.Checked)
        {
            activity.Emergencys = 1;
        }
        else
        {
            activity.Emergencys = 0;
        }

        if (rad7.Checked)
        {
            activity.Repeats = 1;
        }
        else
        {
            activity.Repeats = 0;
        }
        if (rad9.Checked)
        {
            activity.Secrecy = "0";
        }
        else
        {
            activity.Secrecy = "1";
        }

        activity.Appeal_name = this.name.Value;
        activity.Appeal_email = this.email.Value;
        activity.Appeal_tel = this.tel.Value;
        activity.Appeal_type_id = Convert.ToInt32(this.feilei.SelectedItem.Value);
        activity.Appealid = this.biaohao.Value;
        activity.Ascription_id = Convert.ToInt32(this.guishu.SelectedItem.Value);
        activity.Bldwid = "";
        activity.Bm1_type = 9;
        activity.Bm2_type = 9;
        activity.Context = con.Value;
        activity.Current_ld = 0;
        activity.Db_num = 0;
        activity.Handle_type = 0;
        activity.Ischeck = 1;
        activity.Jobnum = Convert.ToInt32(this.num.Value);
        activity.Mp3url = "";
        activity.Regtime = DateTime.Now;
        activity.Reject_num = 0;
        activity.Satisfied = 9;
        activity.Source_id = Convert.ToInt32(this.drot.SelectedItem.Value);
        activity.Title = this.title.Value;
        activity.Xbtime = new DateTime(1900, 01, 01, 00, 00, 00);
        activity.Xialei = Convert.ToInt32(this.xiaolei.SelectedItem.Value);
        activity.Zbtime = new DateTime(1900, 01, 01, 00, 00, 00);
        activity.Zrdwid = "";
        activity.Ischeck = 1;
        activity.Islook0 = 0;
        activity.Islook1 = 0;
        activity.Islook2 = 0;
        activity.Fankuiid = "";
        activity.Banjieid = "";


        if (ProblemManager.Update(activity) > 0)
        {

            Problem_historic2 his = new Problem_historic2();
            his.Blyj = "";
            his.Title = " 呼叫中心，事件录入 ";
            his.Bm2 = "";
            his.Evente = 0;
            his.Idopen = this.biaohao.Value;

            his.Bm1 = ((USER_INFO)Session["users"]).DEPARTMENT;
            his.Item1 = 0;
            his.Item2 = "";
            his.Item3 = "";
            his.Name = ((USER_INFO)Session["users"]).USER_NAME;
            his.Times = DateTime.Now;
            his.Timese = new DateTime(1900, 01, 01, 00, 00, 00);


            Problem_historic2Manager.Save(his);

            Response.Write("<script>alert('上报成功');location.href='index.aspx'</script>");
        }
        else
        {
            Response.Write("<script>alert('上报失败');</script>");
        }


    }
    protected void feilei_SelectedIndexChanged(object sender, EventArgs e)
    {

        try
        {
            this.xiaolei.DataSource = Classification_Appeal2Manager.FindBySort(Convert.ToInt32(this.feilei.SelectedItem.Value));
            this.xiaolei.DataTextField = "name";
            this.xiaolei.DataValueField = "id";
            this.xiaolei.DataBind();

        }
        catch (Exception ex)
        {
            Response.Write("<script>alert('登陆信息失效,请重新登陆!'); window.parent.location.href='/index.html'</script>");
            return;
        }

    }
}